package com.hq.ims.data.vo;

import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.PermissionMapAuthorityUser;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20240929
 */
@Mapper
public interface PermissionMapAuthorityUserMapstruct {

    PermissionMapAuthorityUserMapstruct INSTANCE = Mappers.getMapper(PermissionMapAuthorityUserMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    PermissionMapAuthorityUserVo toPermissionMapAuthorityUserVo(PermissionMapAuthorityUser source);

    default List<PermissionMapAuthorityUserVo> toPermissionMapAuthorityUserVoList(List<PermissionMapAuthorityUser> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toPermissionMapAuthorityUserVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class PermissionMapAuthorityUserVo extends PermissionMapAuthorityUser {

    }

    //-------------------------------- 以下为自定义类[输入对象] --------------------------------


    @ApiModel(value = "绑定用户权限")
    @Data
    class BindUserAuthVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String userId;

        @NotEmpty(message = "权限不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "权限名称")
        private List<String> permissionAuthorityIdList;

        @NotBlank(message = "公司ID", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "公司ID")
        private String companyId;

    }

    //-------------------------------- springboot验证标识 --------------------------------

}
